package com.authine.cloudpivot.ext.dto.system;

import com.authine.mvp.app.launcher.domain.AttachmentFormat;
import com.authine.mvp.app.launcher.domain.SelectorFormat;
import com.authine.mvp.app.org.dto.domainmodel.UnitType;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;
import java.util.Collections;
import java.util.List;

/**
 * @ClassName OrganizationDto
 * @Description: 组织
 * @Author fj
 * @Date 2021/5/4
 * @Version V1.0
 **/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Schema(description = "OrganizationDto")
public class OrganizationDto {
    @Schema(description = "组织id")
    private String id;
    @Schema(description = "父组织id")
    private List<SelectorFormat> parent_id;
    @Schema(description = "账户id")
    private String account_id;
    @Schema(description = "固买业务人员id")
    private List<SelectorFormat> business_member_id;
    @Schema(description = "结算组织id")
    private List<SelectorFormat> transaction_organization_id;
    @Schema(description = "扩展属性")
    private String extends_attr;
    @Schema(description = "组织名称")
    private String name;
    @Schema(description = "父组织名")
    private String parent_name;
    @Schema(description = "固买业务人员名")
    private String business_member_name;
    @Schema(description = "描述")
    private String description;
    @Schema(description = "组织角色集")
    private String role_names;
    @Schema(description = "组织产品线类目")
    private String organization_product_line;
    @Schema(description = "主营")
    private String business_scope;
    @Schema(description = "营业执照号码")
    private String license_code;
    @Schema(description = "信用代码")
    private String credit_identifier;
    @Schema(description = "法人")
    private String legal_representative;
    @Schema(description = "注册资本")
    private String registered_capital;
    @Schema(description = "公司简介")
    private String memo;
    @Schema(description = "采购额")
    private String purchase_quota;
    @Schema(description = "附件")
    private List<AttachmentFormat> attachment;
    @Schema(description = "是否平台供应商")
    private Boolean platform;
    @Schema(description = "是否为虚拟供应商")
    private Boolean virtual;
    @Schema(description = "账单周期(天)")
    private Integer statement_cycle;
    @Schema(description = "每个月几号统一对账策略")
    private Integer reconciliation_day_strategy;
    @Schema(description = "开票后多少天付款策略")
    private Integer payment_day_strategy;
    @Schema(description = "是否小规模供应商")
    private Boolean small_scale;
    @Schema(description = "小规模供应商费率")
    private BigDecimal small_scale_rate;
    @Schema(description = "运费比例")
    private BigDecimal freight_ratio;
    @Schema(description = "支付约定方式")
    private String pay_appoint_way;
    @Schema(description = "销售所属区域")
    private String sales_area;
    @Schema(description = "主要品牌")
    private String major_brand;
    @Schema(description = "限制报价小数位")
    private Integer quotation_decimal_limit;
    @Schema(description = "评级等级")
    private String level;
    @Schema(description = "是否可用")
    private Boolean enabled;
    @Schema(description = "企业联系人")
    private String connect;
    @Schema(description = "手机")
    private String cellphone;
    @Schema(description = "邮箱")
    private String email;
    @Schema(description = "QQ")
    private String qq;
    @Schema(description = "平台id")
    private List<SelectorFormat> platform_id;
    @Schema(description = "平台名")
    private String platform_name;
    @Schema(description = "邀请人")
    private List<SelectorFormat> invite_user;
    @Schema(description = "是否精准匹配供应商")
    private Boolean goods_automatic_matching;
    // 系统管理组织id存储的是云枢根部门id，但是修改时需要用到组织id，故加此字段
    @Schema(description = "云枢组织id")
    private String muti_org_id;
    /**
     * api接口查询需要用到的字段
     */
    @Schema(description = "账户id，查询用，可传多个")
    private List<String> accountIds;
    @Schema(description = "组织id，查询用，可传多个")
    private List<String> ids;
    @Schema(description = "角色名称，查询用，可传多个")
    private List<String> roleNames;
    @Schema(description = "客户id，接口查询用")
    private String customerId;
    @Schema(description = "供应商id，接口查询用")
    private String vendorId;

    public SelectorFormat createSelectorFormat() {
        SelectorFormat selectorFormat = new SelectorFormat();

        selectorFormat.setName(name);
        selectorFormat.setId(id);
        selectorFormat.setType(UnitType.DEPARTMENT.getIndex());
        return selectorFormat;
    }

    public List<SelectorFormat> createSelectorFormatList() {
        return Collections.singletonList(createSelectorFormat());
    }

}
